package com.utooo.service.supplier;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.utooo.dao.purchase.BuyerInvoiceMapper;
import com.utooo.dao.supplier.SupplierInvoiceMapper;
import com.utooo.pojo.domain.invoice.BuyerInvoiceDO;
import com.utooo.pojo.domain.invoice.SupplierInvoiceDO;
import com.utooo.pojo.domain.supplier.execute.BuyerDeliveryPlanDO;
import com.utooo.pojo.dto.invoice.InvoicePushDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import static com.utooo.constant.Constans.IGNORED_PROPERTIES;

/**
 * @Description: TODO
 * @Author SJD
 * @Date: 2025/4/25 11:37
 * @Copyright: 南京优通信息科技股份有限公司
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class SupplierInvoiceServiceImpl extends ServiceImpl<SupplierInvoiceMapper, SupplierInvoiceDO> implements SupplierInvoiceService{
    private final SupplierInvoiceMapper supplierInvoiceMapper;
    private final BuyerInvoiceMapper buyerInvoiceMapper;
    @Override
    public Boolean pushInvoice(InvoicePushDto param) {
        SupplierInvoiceDO invoiceDO = supplierInvoiceMapper
                .selectOne(new LambdaQueryWrapper<SupplierInvoiceDO>().eq(SupplierInvoiceDO::getInvoiceNumber, param.getInvoiceNumber()));
        BuyerInvoiceDO buyerInvoiceDO = BeanUtil.copyProperties(invoiceDO, BuyerInvoiceDO.class, IGNORED_PROPERTIES);
        buyerInvoiceMapper.insert(buyerInvoiceDO);
        return true;
    }
}
